import { request } from '@/utils/request';
import Api from '@/core/permission/modules/sup/case-management';
import { publicApi } from '@/core/permission/modules/public/params';

/**
 * @description 获取列表
 * @param {API.GetCaseInfoListRequest} data
 * @returns
 */
export function getCaseInfoList(data: API.GetCaseInfoListRequest) {
  return request({
    url: Api.list,
    method: 'post',
    data,
  });
}

/**
 * @description 添加立案信息
 * @param {API.SaveRegisterQuery} data
 * @returns
 */
export function insertCaseInfo(data: API.SaveRegisterQuery) {
  return request(
    {
      url: Api.save,
      method: 'post',
      data,
    },
    {
      isGetDataDirectly: false,
    },
  );
}

/**
 * @description 编辑立案信息
 * @param {API.SaveRegisterQuery} data
 * @returns
 */
export function editCaseInfo(data: API.SaveRegisterQuery) {
  return request(
    {
      url: Api.updata,
      method: 'put',
      data,
    },
    {
      isGetDataDirectly: false,
    },
  );
}

/**
 * @description 获取案件详情
 * @returns
 */
export function caseDetail(caseId: any) {
  return request({
    url: Api.info + `/${caseId}`,
    method: 'get',
  });
}

/**
 * @description 删除案件信息
 * @returns
 */
export function deleteCaseInfo(caseId: any) {
  return request({
    url: Api.delete + `/${caseId}`,
    method: 'delete',
  });
}

/**
 * @description 案件办理
 * @returns
 */
export function handleCase(data) {
  return request(
    {
      url: Api.case,
      method: 'put',
      data,
    },
    {
      isGetDataDirectly: false,
    },
  );
}

/**
 * @description 获取案件来源字典
 * @returns
 */
export function getFromType() {
  return request(
    {
      url: publicApi.from_type,
      method: 'get',
    },
    {
      isGetDataDirectly: false,
    },
  );
}

/**
 * @description 获取立案意见字典
 * @returns
 */
export function getCaseOption() {
  return request(
    {
      url: publicApi.case_option,
      method: 'get',
    },
    {
      isGetDataDirectly: false,
    },
  );
}

/**
 * @description 获取区域数据
 * @returns
 */
export function getAreaList() {
  return request(
    {
      url: publicApi.area,
      method: 'get',
    },
    {
      isGetDataDirectly: false,
    },
  );
}

/**
 * @description 获取案由列表
 * @param {API.GetCaseActionPageListRequest} data
 * @returns
 */
export function getCaseActionPageList(data: API.GetCaseActionPageListRequest) {
  return request({
    url: '/manage/admin/caseAction/pageList',
    method: 'post',
    data,
  });
}
